package com.sanpu.kxe.module.dialog;

import android.content.Context;
import android.support.annotation.DrawableRes;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.sanpu.kxe.R;
import com.sanpu.kxe.base.BaseDialog;

import butterknife.ButterKnife;

/**
 * Description：文字提示的dialog
 * Created by 薛勇军 on 2018/7/9.
 */

public class HintDialog extends BaseDialog<HintDialog> {
    private TextView close;

    private LinearLayout vContent;
    private TextView vTitle;
    private int image;
    private String title;
    private View contentView;

    public HintDialog content(View content) {
        this.contentView = content;
        return this;
    }

    public HintDialog(Context context) {
        super(context);
    }

    @Override
    public View onCreateView() {
        showAnim(new BaseAnimatorSet() {
            @Override
            public void setAnimation(View view) {

            }
        });
        View inflate = View.inflate(getContext(), R.layout.dialog_hint, null);
        vContent = ButterKnife.findById(inflate, R.id.content);
        vTitle = ButterKnife.findById(inflate, R.id.title);
        close = ButterKnife.findById(inflate, R.id.close);
//        inflate.setPadding(dp2px(15), dp2px(15), dp2px(15), dp2px(15));

        if (image != 0) {
            ButterKnife.findById(inflate, R.id.header).setBackgroundResource(image);
        }
        if (!TextUtils.isEmpty(title)) {
            vTitle.setVisibility(View.VISIBLE);
            vTitle.setText(title);
        }
        return inflate;
    }

    @Override
    public void setUiBeforShow() {
        vContent.addView(contentView);
        close.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

    public HintDialog image(@DrawableRes int img) {
        this.image = img;
        return this;
    }

    public HintDialog title(String title) {
        this.title = title;
        return this;
    }
}